﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T2oop
{
    class Contact
    {
        private string name;
        private string homePhone;
        private string mobilePhone;
        private string busiPhone;
        private string fax;
        //只读属性
        public  string  Name
        {
            get { return name; }

        }
        public Contact(string name)
        {
            this.name = name;
        }
        //索引方式
        public  string  this[string  type]
        {
            get
            {
                switch(type)
                {
                    case "mobile": return mobilePhone;
                    case "home": return homePhone;
                    case "business":return busiPhone;
                    case "fax":return fax;
                    default:return "none";
                }
            }
            set
            {
                switch(type)
                {
                    case "mobile": mobilePhone = value;break;
                    case "home": homePhone = value;break;
                    case "business": busiPhone = value;break;
                    case "fax":  fax = value;break;
               
                }
            }
        }
 

        public override string ToString()
        {
            return string.Format("联系人信息：【{0}】---【{1}】--【{2}】--【{3}】", mobilePhone, homePhone, busiPhone, fax);
        }
    }
}
